﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;
using System.Collections.Generic;
using SilverlightApp.data;
using System.Collections;
using System.Collections.ObjectModel;
using SilverlightApp.Common;

namespace SilverlightApp.Web
{

    public class HumidityChartBuilder2 : ColumnChartBuilderBase
    {

        protected override void AfterSeriesBuild(ColumnSeries series)
        {
            series.Width = 100;
        }

        protected override void AfterChartBuild(Chart chart)
        {
            chart.Height = 230;
            //warningDispatcherTimer.Interval
        }

        protected override void AfterLinearAxisBuild(LinearAxis la)
        {
            la.Interval = 20;
        }

        public override void BuildChart(Panel panel, MyObservableCollection<PairInfo> ds)
        {
            ColumnChartBuildContext bc = new ColumnChartBuildContext();
            bc.ChartTitle = "湿度监控";
            bc.ColumnColor = Colors.Blue;
            bc.DataSource = ds;
            //bc.WarningMaxValue = 60;
            //bc.WarningMinValue = 20;
            bc.AfterPropertyChangedEnventHandler = (chart, self) =>
            {
                if (self != null && self.Count > 0)
                {
                    chart.Title = string.Format("湿度监控" + Environment.NewLine + "({0}%)", Math.Round(self[0].Value, 2));
                    if (self[0].Value < 20 || self[0].Value > 60)
                    {
                        //StartDispatcherTimer();
                    }
                    else
                    {
                        //EndDispatcherTimer();
                    }
                }
            };
            BuildChartCore(panel, bc);
            return;
        }
    }
}
